<!DOCTYPE html>


<html lang="zh-CN">
  

    <head>
      <meta charset="utf-8" />
        
      <meta name="description" content="欢迎与我交流自动化测试、测试开发、持续集成、DevOps方面知识经验，可在评论区留言。" />
      
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
      <title>调试JMeter5源码 |  恰得福来的博客</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/favicon.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css"
      />
      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    <link rel="alternate" href="/atom.xml" title="恰得福来的博客" type="application/atom+xml">
</head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-调试JMeter5源码"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  调试JMeter5源码
</h1>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2021/09/08/%E8%B0%83%E8%AF%95JMeter5%E6%BA%90%E7%A0%81/" class="article-date">
  <time datetime="2021-09-08T15:56:00.000Z" itemprop="datePublished">2021-09-08</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/jmeter/">jmeter</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">1.1k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">4 分钟</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="JMeter源码的开发调试"><a href="#JMeter源码的开发调试" class="headerlink" title="JMeter源码的开发调试"></a>JMeter源码的开发调试</h1><h2 id="说明"><a href="#说明" class="headerlink" title="说明"></a>说明</h2><p>本文编译这部分内容基本来源于网上。debug相关内容为本人根据实际情况整理。</p>
<p>JMeter5.2开始，使用gradle代替了原来ant，所以基于源码的本地环境搭建略有不同。JMeter 5.4.1使用的gradle文件不是build.gradle文件，而是build.gradle.kts。</p>
<h2 id="所需环境"><a href="#所需环境" class="headerlink" title="所需环境"></a>所需环境</h2><ul>
<li>JDK 8 +</li>
<li>JMeter 源码（本例使用的是5.4.1版本）</li>
<li>IntelliJ IDEA / Eclipse：本例使用IntelliJ IDEA CE 2020.3来构建本地开发环境（IDEA版本需要&gt;=2018.3.1）</li>
</ul>
<h2 id="编译"><a href="#编译" class="headerlink" title="编译"></a>编译</h2><p>下面是在IDEA打开JMeter工程的步骤说明。</p>
<ol>
<li><p>启动idea，点击File -&gt; open，选中jmeter源码目录下build.gradle.kts</p>
</li>
<li><p>选择“Open as Project”</p>
</li>
<li><p>确保“Create separate module per source set” 和 “Use default gradle wrapper”选中，然后点击ok。（这两项不一定会有，可能和IDEA版本有关）</p>
</li>
</ol>
<p>随后idea会自动开始下载JMeter所需依赖，等待执行完成。</p>
<p><strong>注意 这里不要对Gradle设置阿里云镜像，否则会出现依赖加载不成功，在checksum时，会有部分依赖报错，开始前建议暂时取消Gradle的镜像。</strong></p>
<blockquote>
<p>为了不使用ali的gradle仓库，我把~/.gradle下的init.gradle（使用了ali的gradle库）重命名为init.gradle.bak了，这样gradle在运行的时候不再使用ali的库。</p>
</blockquote>
<p>依赖下载完成后，所需的依赖是在gradle的cache目录下，我们需要执行命令打包构建，将所需的依赖复制一份到jmeter源码目录的lib目录下。在Terminal中执行（gradle需要先配置环境变量）<code>gradlew runGui</code>。或在gradle任务下的developement下执行runGUI，以便在工程根目录下的lib下生成相关jar。</p>
<p>执行完成后，会打开构建好的jmeter GUI界面。查看lib目录，jar包也已复制完成。在调试之前，先关闭打开的JMeter界面。</p>
<h2 id="在IDEA中debug源码"><a href="#在IDEA中debug源码" class="headerlink" title="在IDEA中debug源码"></a>在IDEA中debug源码</h2><p>下面是debug设置的操作说明：</p>
<ol>
<li><p>在IDEA中，快捷键cmd+shift+f或double shift（mac电脑），搜索找到NewDriver类。</p>
</li>
<li><p>点击小锤子旁边的 Add Configuration…</p>
</li>
<li><p>增加Application设置，在VM options中加入 -Djmeter.home=xxx（JMeter源码目录），点击ok。</p>
</li>
</ol>
<p>对于jmeter 5.4.1 ，为了debug jmeter，我是这样设置的:</p>
<ol>
<li>修改run configuration如下：</li>
</ol>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">vm option：</span><br><span class="line">-Djmeter.home=/Users/lizhiqiang/Test/src/jmeter -cp .;/Users/lizhiqiang/Test/src/jmeter</span><br><span class="line"></span><br><span class="line">classname：</span><br><span class="line">org.apache.jmeter.NewDriver</span><br><span class="line"></span><br><span class="line">environment variables:</span><br><span class="line">JMETER_HOME=/Users/lizhiqiang/Test/src/jmeter</span><br></pre></td></tr></table></figure>

<ol start="2">
<li><p>生成lib下相关jar（<strong>如果之前已经执行过runGUI，不需要再执行</strong>）</p>
</li>
<li><p>修改代码</p>
</li>
</ol>
<p>因为代码逻辑设定，所以为了启动debug，需要修改少量代码。如果不修改代码，debug的时候会报错。因此在line 87行添加一行：<code>tmpDir = null; //lizhiqiang debug</code>。（可能是我的野路子）。记得这行代码在正式发布的时候去除或注释掉！</p>
<p>修改后这段代码是这样的：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">tmpDir = <span class="keyword">null</span>; <span class="comment">//lizhiqiang debug</span></span><br><span class="line"><span class="keyword">if</span> (tmpDir == <span class="keyword">null</span>) &#123;</span><br><span class="line">    tmpDir = System.getenv(<span class="string">&quot;JMETER_HOME&quot;</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>这样，程序将使用环境变量JMETER_HOME定义的目录.</p>
<ol start="4">
<li>点击debug按钮，运行代码，随后会启动JMeter的GUI了，接下来我们就可以在想了解功能上，打断点或者修改源码，调试JMeter。</li>
</ol>
<h2 id="debug时相关错误"><a href="#debug时相关错误" class="headerlink" title="debug时相关错误"></a>debug时相关错误</h2><p>尝试使用过下面的命令，但可能都不是正确的方式，因为后面尝试了都不能将jmeter启动起来，最终还是按照之前提过的方法，不实用ali的仓库进行构建。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">检查校验和：构建完成后才检查校验和</span></span><br><span class="line">./gradlew clean build -Djava.awt.headless=true -PchecksumFailOn=build_finish</span><br><span class="line">-PchecksumFailOn=build_finish</span><br><span class="line"><span class="meta"></span></span><br><span class="line"><span class="meta">#</span><span class="bash">不检查校验和，也不测试</span></span><br><span class="line">./gradlew clean build -Djava.awt.headless=true -PchecksumIgnore -x test</span><br></pre></td></tr></table></figure>

<p>下面是默认执行<code>gradle build</code>时出现的错误。这些校验和相关的错误要解决，否则可能后面还是不能运行成功。解决的方法在前面提过，就是不要使用ali的仓库（至少在我的实践看来是这样的。原因可能还是因为某些依赖的包不再ali的仓库里）：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">错误信息：</span><br><span class="line">Checksum/PGP violations detected on resolving configuration :src:testkit-wiremock:compileClasspath</span><br><span class="line">  No PGP signature (.asc file) found for artifact:</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>下面的错误不记得是如何消除的了，但比较确定的一点是，没有checksum相关的错误后，下面的错误也没了：</p>
<ul>
<li>jmeter Caused by: java.io.FileNotFoundException:   subprojects/configuration-cache/src/main/kotlin (Is a directory)</li>
<li>其他一些错误：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">Create separate module per source set</span><br><span class="line">Task :src:components:autostyleJavaCheck FAILED</span><br><span class="line">src:bshclient:autostyleJavaCheck FAILED</span><br><span class="line"> Task :src:testkit-wiremock:compileJava FAILED</span><br><span class="line">java/org/apache/jorphan/gui/DynamicStyle.java使用了未经检查或不安全的操作</span><br></pre></td></tr></table></figure>

<h2 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h2><p>构建文档：</p>
<ul>
<li><a target="_blank" rel="noopener" href="https://github.com/apache/jmeter/blob/master/gradle.md">https://github.com/apache/jmeter/blob/master/gradle.md</a> 官方构建说明，可以找到关于不同构建命令的说明</li>
</ul>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>版权声明： </strong>
          
          本博客所有文章除特别声明外，著作权归作者所有。转载请注明出处！
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://johnny1952.github.io/2021/09/08/%E8%B0%83%E8%AF%95JMeter5%E6%BA%90%E7%A0%81/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/debug/" rel="tag">debug</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/jmeter/" rel="tag">jmeter</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2021/09/09/Maven%E5%B8%B8%E7%94%A8%E4%BB%93%E5%BA%93%E5%8F%8A%E9%85%8D%E7%BD%AE%E5%A4%9A%E4%BB%93%E5%BA%93/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            Maven常用仓库及配置多仓库
          
        </div>
      </a>
    
    
      <a href="/2021/09/05/%E4%BD%BF%E7%94%A8pyecharts%E7%BB%98%E5%88%B6%E7%B3%BB%E7%BB%9F%E4%BE%9D%E8%B5%96%E5%85%B3%E7%B3%BB%E5%9B%BE/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">使用pyecharts绘制系统依赖关系图</div>
      </a>
    
  </nav>

   
<!-- valine评论 -->
<div id="vcomments-box">
  <div id="vcomments"></div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js"></script>
<script>
  new Valine({
    el: "#vcomments",
    app_id: "BDYyK8ADltP2ULGCnAJe5ufP-gzGzoHsz",
    app_key: "yCqG1hemYrFKJahvOBl6uppH",
    path: window.location.pathname,
    avatar: "monsterid",
    placeholder: "你有什么想法或问题？快来评论一下吧!",
    recordIP: true,
  });
  const infoEle = document.querySelector("#vcomments .info");
  if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
    infoEle.childNodes.forEach(function (item) {
      item.parentNode.removeChild(item);
    });
  }
</script>
<style>
  #vcomments-box {
    padding: 5px 30px;
  }

  @media screen and (max-width: 800px) {
    #vcomments-box {
      padding: 5px 0px;
    }
  }

  #vcomments-box #vcomments {
    background-color: #fff;
  }

  .v .vlist .vcard .vh {
    padding-right: 20px;
  }

  .v .vlist .vcard {
    padding-left: 10px;
  }
</style>

 
   
     
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2021
        <i class="ri-heart-fill heart_icon"></i> Johnny Li
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>访问人数:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>浏览次数:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1280251923&amp;web_id=1280251923'></script>
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="恰得福来的博客"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="https://johnny1952.github.io/gitbook-tutorial">gitbook</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="搜索">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/img/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/img/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->
 
<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: ".tocbot",
    contentSelector: ".article-entry",
    headingSelector: "h1, h2, h3, h4, h5, h6",
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: "main",
    positionFixedSelector: ".tocbot",
    positionFixedClass: "is-position-fixed",
    fixedSidebarOffset: "auto",
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->
 <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script> 
<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>